<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="base" uri="http://qdbp.gitee.io/tags/base/"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<link href="<base:url href='assets/base/core/bootstrap/bs-common.css'/>" rel="stylesheet" type="text/css" />

<div class="hide x-initial" data-options="{fixedParams:{sceneType:'default'}}"></div>

<table class="x-datagrid main-datalist"
		data-options="toolbar:'.toolbar-box',
		method:'POST',url:'<base:url href='actions/area-division/list.json' />',
		fixedParams:{ordering:'type asc, parentCode asc, sortIndex asc, areaCode asc'},
		idField:'areaCode',parentField:'parentCode',treeField:'areaName',
		xextra:{fields:[{field:'Area',key:'areaCode',value:'areaName',parent:'parentCode'}],map:{Area:'body'}}">
	<thead>
		<tr>
			<th data-options="field:'areaName',width:200,align:'center',xpopup:'update'">名称</th>
			<th data-options="field:'shortName',width:120,align:'center'">简称</th>
			<th data-options="field:'areaCode',width:100,align:'center'">编号</th>
		</tr>
	</thead>
</table>

<div class="hide">
	<div class="toolbar-box">
		<form>
			<div class="toolbar-item">
				<input type="hidden" name="deptCodeStarts" />
				<span class="toolbar-text">编号:</span><input type="text" name="areaCodeStarts" class="x-textbox panel-input"/>
				<span class="toolbar-text">名称:</span><input type="text" name="areaNameLike" class="x-textbox panel-input"/>
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'search',iconCls:'fa fa-search'">查询</a>
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'reset'<%--,iconCls:'fa fa-circle-thin'--%>">重置</a>
				<div class="clear"></div>
			</div>
			<div class="toolbar-item">
				<%-- <a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'detail',selection:'single',iconCls:'fa fa-file-text-o'">详情</a> --%>
				<%--
				<shiro:hasPermission name="area-division:default:create">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'create',iconCls:'fa fa-plus',fillData:false">创建</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="area-division:default:update">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'update',selection:'single',iconCls:'fa fa-pencil'">修改</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="area-division:default:delete">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'delete',selection:'multi',iconCls:'fa fa-minus',fillData:true">删除</a>
				</shiro:hasPermission>
				--%>
				<shiro:hasPermission name="area-division:default:import">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'import',iconCls:'fa fa-sign-in'">导入</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="area-division:default:export">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'export',iconCls:'fa fa-sign-out'">导出</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="area-division:default:sync">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'sync',iconCls:'fa fa-refresh',onBeforeFillData:onBeforeFillDataOfSync">同步</a>
				</shiro:hasPermission>
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'test',iconCls:'fa fa-search-plus',onBeforeFillData:onBeforeFillDataOfTest">测试</a>
			</div>
			<div class="clear"></div>
		</form>
	</div>

	<div class="x-dialog container-fluid" title="地址选择" data-options="xpopup:'test',width:800,height:300,modal:true,iconCls:'fa fa-search-plus'">
		<form class="pure-box form-horizontal">
			<dd>
				<div class="form-group compact">
					<div class="col-md-2 control-label">行政区划</div>
					<div class="col-md-9 control-input area-division-box" 
							data-options="suggestionUrl:'<base:url href='actions/area-core/suggestion.json'/>',
								townshipUrl:'<base:url href='actions/area-core/township.json'/>',
								areaDivisionsUrl:'<base:url href='actions/area-core/area-divisions.json'/>'<%--,
								ipLocatingUrl:'<base:url href='actions/area-core/ip-locating.json'/>'--%>">
						<input type="hidden" name="areaCode" />
						<input type="hidden" name="township" />
						<input class="form-control" type="text" name="areaText" data-vld="{required:true}" placeholder="选择行政区划" />
						<div class="vld-tips"></div>
						<div class="area-division-panel active hide">
							<div class="border">
								<a class="close-icon"><span class="icon fa fa-times"></span></a>
								<%--
								<div class="switch-panel hide">
									<div class="input-box">
										<input class="form-control" type="text" name="inputText" placeholder="输入街道、乡镇、小区或商圈名称" />
									</div>
									<ul class="addresses">
									</ul>
									<a class="switch-link plain">手动选择行政区划&nbsp;&gt;&gt;</a>
								</div>
								--%>
								<div class="switch-panel">
									<div>
										<ul class="choose-title">
											<li class="province color-warn"><a>选择省份/自治区</a></li>
											<li class="city color-warn hide"><a>选择城市/地区</a></li>
											<li class="district color-warn hide"><a>选择区/县</a></li>
										</ul>
									</div>
									<div>
										<ul class="choose-items">
										</ul>
									</div>
									<%-- <a class="switch-link plain">搜索地址快速定位&nbsp;&gt;&gt;</a> --%>
								</div>
								<div class="hide">
									<script type="address-template">
									<# $.each(this, function() { #>
										<li data-area-code="<#=this.areaCode#>" data-location="<#=this.location#>">
											<div> <#=this.placeName#> </div>
											<div class="color-weak"> <#=this.areaText#> <#=this.address#> </div>
											<div class="resolve vertical-middle"><a class="btn btn-default btn-sm">选择</a></div>
										</li>
									<# }); #>
									</script>
									<script type="choose-item-template">
									<# $.each(this, function() { #>
										<li data-area-code="<#=this.areaCode#>"><a><#=this.shortName||this.areaName#></a></li>
									<# }); #>
									</script>
								</div>
							</div>
						</div>
					</div>
				</div>
			</dd>
		</form>
		<div class="dialog-button">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>

	<div class="x-dialog container-fluid" title="创建" data-options="xpopup:'create',width:500,modal:true,iconCls:'fa fa-plus'">
		<form class="pure-box form-horizontal" method="POST" action="<base:url href='actions/area-division/create.json'/>">
			<dd>
				<div class="spacer-right">
					<div class="form-group">
						<div class="col-md-3 control-label"><i class="asterisk"></i>上级:</div>
						<div class="col-md-9 control-input"><input class="x-combotree" type="text" name="parentCode" data-options="editable:false,xextra:{field:'Area',prepend:{key:'0',value:'中国'},ignore:{type:['DISTRICT']}}"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label"><i class="asterisk"></i>编号</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="areaCode" data-options="required:true,validType:['areaCode','length[0,10]']"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label"><i class="asterisk"></i>名称</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="areaName" data-options="validType:['illegalChar','length[0,30]']"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">简称</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="shortName" data-options="validType:['illegalChar','length[0,20]']"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">排序</div>
						<div class="col-md-9 control-input"><input class="x-numberbox" type="text" name="sortIndex" data-options="min:0,validType:'length[0,8]'"/></div>
					</div>
				</div>
			</dd>
		</form>
		<div class="dialog-button">
			<shiro:hasPermission name="area-division:default:create">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save',closeOnSuccess:false,clearOnSuccess:true,message:'保存'">保存并继续</a>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save'">保存</a>
			</shiro:hasPermission>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>

	<div class="x-dialog container-fluid" title="地区信息" data-options="xpopup:'update',width:500,modal:true,iconCls:'fa fa-pencil'">
		<form class="pure-box form-horizontal" method="POST" action="<base:url href='actions/area-division/update.json'/>">
			<dd>
				<input type="hidden" name="id" />
				<div class="spacer-right">
					<div class="form-group">
						<div class="col-md-3 control-label">上级:</div>
						<div class="col-md-9 control-input"><input class="x-combotree" type="text" name="parentCode" data-options="readonly:true,xextra:{field:'Area',prepend:{key:'0',value:'中国'}}"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">编号</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="areaCode" data-options="readonly:true"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label"><i class="asterisk"></i>名称</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="areaName" data-options="validType:['illegalChar','length[0,30]']"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">简称</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="shortName" data-options="validType:['illegalChar','length[0,20]']"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">排序</div>
						<div class="col-md-9 control-input"><input class="x-numberbox" type="text" name="sortIndex" data-options="min:0,validType:'length[0,8]'"/></div>
					</div>
				</div>
			</dd>
		</form>
		<div class="dialog-button">
			<shiro:hasPermission name="area-division:default:update">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save'">保存</a>
			</shiro:hasPermission>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>
	<div class="x-dialog container-fluid" title="删除" data-options="xpopup:'delete',width:500,modal:true,iconCls:'fa fa-minus'">
		<form class="pure-box form-horizontal" method="POST" action="<base:url href='actions/area-division/delete.json'/>">
			<dd>
				<div class="spacer-right">
					<input type="hidden" name="id" />
					<div class="form-group">
						<div class="col-md-3 control-label">编号</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="areaCode" data-options="readonly:true"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">名称</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="areaName" data-options="readonly:true"/></div>
					</div>
					<div class="form-group text-center">
						<span class="color-warn">一旦删除关联数据将会失效且无法恢复!</span><br>确定删除该地区?
					</div>
				</div>
			</dd>
		</form>
		<div class="dialog-button">
			<shiro:hasPermission name="area-division:default:delete">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-check',message:'删除'">确定</a>
			</shiro:hasPermission>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>
	<div class="x-dialog ptb-sm" title="导入" data-options="xpopup:'import',width:500,modal:true,iconCls:'fa fa-sign-in'">
		<form method="POST" action="<base:url href='actions/area-division/import.json'/>" enctype="multipart/form-data">
			<table cellpadding="3" align="center">
				<tr>
					<td><input class="x-filebox panel-input" name="excel" data-options="required:true,width:300,validType:['extension[\'excel(xlsx)\',\'xlsx\']'],prompt:'请选择导入的excel',buttonText:'选择'"></td>
					<td><div class="ui-loading-icon state-icon"></div></td>
				</tr>
			</table>
		</form>
		<div class="dialog-button">
			<a href="<base:url href='actions/webfile/download.do'/>?path=assets/excel/area-data.xlsx&filename=行政区划数据.xlsx" class="x-linkbutton" data-options="iconCls:'fa fa-download'">下载数据</a>
			<a href="<base:url href='actions/webfile/download.do'/>?path=assets/excel/area-division.xlsx&filename=行政区划模板.xlsx" class="x-linkbutton" data-options="iconCls:'fa fa-download'">下载空模版</a>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'import',iconCls:'fa fa-save'">提交</a>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>
	<div class="x-dialog" title="警告" data-options="xpopup:'import-failed',width:500,height:350,modal:true,iconCls:'fa fa-warning'">
		<div class="import-failed-text text-center">共导入成功 <span class="records success"></span> 条, 失败 <span class="records failed"></span> 条</div>
		<table class="x-datagrid" data-options="toolbar:'.import-failed-text',fit:true,border:false,fitColumns:true,singleSelect:true,pagination:false">
			<thead>
				<tr>
					<th data-options="field:'index',width:36,align:'center'">行数</th>
					<th data-options="field:'field',width:100,align:'center'">字段</th>
					<th data-options="field:'message',width:250,align:'center'">原因</th>
				</tr>
			</thead>
		</table>
		<div class="dialog-button">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">关闭</a>
		</div>
	</div>
	<div class="x-dialog ptb-sm" title="导出" data-options="xpopup:'export',width:500,modal:true,iconCls:'fa fa-sign-out'">
		<table cellpadding="3" align="center">
			<tr>
				<td><span class="toolbar-text">确认导出当前条件筛选的全部数据吗?</span></td>
				<td><div class="ui-loading-icon state-icon"></div></td>
			</tr>
		</table>
		<div class="dialog-button">
			<a href="javascript:void(0)" data-href="<base:url href='actions/area-division/export.do'/>?filename=行政区划表.xlsx" class="x-linkbutton" data-options="iconCls:'fa fa-save',onClick:xfn.popup.export">确定</a>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>
	<div class="x-dialog" title="从高德地图同步最新数据" data-options="xpopup:'sync',width:900,height:500,modal:true,iconCls:'fa fa-refresh'">
		<div class="sync-prompt text-center ptb-xs">
			<span class="before"><span class="color-warn">操作步骤: </span>先比对数据, 显示变动情况, 再同步数据</span>
			<span class="compare-doing hide"><i class="icon-loading"></i> <span class="color-warn">正在对比, 请稍候...</span></span>
			<span class="save-doing hide"><i class="icon-loading"></i> <span class="color-warn">正在保存, 请稍候...</span></span>
			<span class="after hide">以下是变动情况, 如有需要请<span class="color-warn">同步数据</span></span>
			<span class="empty hide">比对成功, 数据没有任何变动...</span>
		</div>
		<table class="x-datagrid" data-options="toolbar:'.sync-prompt',fit:true,border:false,fitColumns:true,singleSelect:true,pagination:false">
			<thead>
				<tr>
					<th data-options="field:'areaCode',width:70,align:'center',formatter:format.changedAreaCode">编号</th>
					<th data-options="field:'type',width:50,align:'center',formatter:format.changedChangeType">类型</th>
					<th data-options="field:'message',width:780,align:'left',halign:'center',formatter:format.changedMessage">说明</th>
				</tr>
			</thead>
		</table>
		<div class="dialog-button">
			<a href="javascript:void(0)" class="x-linkbutton do-compare" data-options="xclick:onClickOfStartCompare,url:'<base:url href='actions/area-division/compare.json'/>',iconCls:'fa fa-retweet'">开始比对</a>
			<a href="javascript:void(0)" class="x-linkbutton do-save" data-options="xclick:onClickOfSaveChanged,disabled:true,url:'<base:url href='actions/area-division/sync-data.json'/>',iconCls:'fa fa-save'">同步数据</a>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">关闭</a>
		</div>
	</div>
	
</div>

<script src="<base:url href='assets/base/core/bootstrap/bs-common.js'/>"></script>
<script src="<base:url href='assets/${pv.view}.js'/>"></script>
